﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MakeIT.MiraPark.Negocios;
using MakeIT.MiraPark.Apresentacao.Estatisticas;
using MakeIT.MiraPark.Apresentacao.Estatisticas.EstatisticasTableAdapters;
using Microsoft.Reporting.WinForms;

namespace MiraPark
{
    public partial class FormReportMensalista : Form
    {
        public FormReportMensalista()
        {
            InitializeComponent();
        }
        private void FormReportMensalista_Load(object sender, EventArgs e)
        {
            List<MensalistaVO> listMensalistaVOs = ModelBO.getMensalistas(true);
            this.comboBoxMensalista.DataSource = listMensalistaVOs;
        }

        private void buttonImprimir_Click(object sender, EventArgs e)
        {
            DateTime dtIni = this.dateTimePicker1.Value;
            dtIni = dtIni.AddDays((dtIni.Day - 1) * -1);
            DateTime dtFim = dtIni.AddMonths(1).AddDays(-1);

            int idMensalista = (int)this.comboBoxMensalista.SelectedValue;

            this.reportViewer1.LocalReport.DataSources.Clear();

            mensalistaTableAdapter ta = new mensalistaTableAdapter();
            MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaDataTable dt = new MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaDataTable();
            dt = ta.GetData(idMensalista);
            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Estatisticas_mensalista",(DataTable) dt));
            //this.reportViewer1.RefreshReport();

            mensalistaMovimentoTableAdapter mmta = new mensalistaMovimentoTableAdapter();
            MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaMovimentoDataTable mmdt = new MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaMovimentoDataTable();
            mmdt = mmta.GetData(idMensalista, dtIni,dtFim);
            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Estatisticas_mensalistaMovimento", (DataTable) mmdt));

            mensalistaVeiculoTableAdapter mvta = new mensalistaVeiculoTableAdapter();
            MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaVeiculoDataTable mvdt = new MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaVeiculoDataTable();
            mvdt = mvta.GetData(idMensalista);
            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Estatisticas_mensalistaVeiculo", (DataTable)mvdt));

            mensalistaFranquiaTableAdapter mfta = new mensalistaFranquiaTableAdapter();
            MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaFranquiaDataTable mfdt = new MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaFranquiaDataTable();
            mfdt = mfta.GetData(idMensalista, dtIni, dtFim);
            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Estatisticas_mensalistaFranquia", (DataTable)mfdt));

            mensalistaPagamentoTableAdapter mpta = new mensalistaPagamentoTableAdapter();
            MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaPagamentoDataTable mpdt = new MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaPagamentoDataTable();
            mpdt = mpta.GetData(idMensalista, dtIni, dtFim);
            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Estatisticas_mensalistaPagamento", (DataTable)mpdt));

            mensalistaPagementoAbertoTableAdapter mpata = new mensalistaPagementoAbertoTableAdapter();
            MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaPagementoAbertoDataTable mpadt = new MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.mensalistaPagementoAbertoDataTable();
            mpadt = mpata.GetData(idMensalista, dtIni, dtFim);
            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Estatisticas_mensalistaPagementoAberto", (DataTable)mpadt));

            this.reportViewer1.RefreshReport();
        }

    }
}
